<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 

<html>
<head>
<title>Menu_Groups</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<?XML:NAMESPACE PREFIX="MYTREE">
<?IMPORT NAMESPACE="MYTREE" IMPLEMENTATION="/webctrl_client_d/1_0/treeview.htc" >
<LINK rel="stylesheet" type="text/css" href="/CSS/Outlook.css">
<LINK rel="stylesheet" type="text/css" href="/CSS/navbar.css">
</head>
<BODY MS_POSITIONING="GridLayout" onload="page_Load()">
<TABLE>
	<TR valign="top">
		<TD>
			NameSpace: <SELECT id="selNS" runat="server" onchange="showGroups()" NAME="selNS"></SELECT><BR>
			<MYTREE:TREEVIEW ID="oTree" SELECTEDNODEINDEX="0" SHOWPLUS="false" EXPANDLEVEL="0" onnodebound="cropWindow()" DEFAULTSTYLE="FONT-WEIGHT: bold; FONT-SIZE: 8pt; FONT-FAMILY: Tahoma;COLOR:darkred" onselectedindexchange="showGroups()" SYSTEMIMAGESPATH="/webctrl_client/1_0/TreeImages/">
				<ASP:LITERAL ID="ltrMenuTree" Runat="server"></ASP:LITERAL>
			</MYTREE:TREEVIEW>
		</TD>
		<TD valign="top">
			<SELECT id="selGroups" runat="server" onchange="chkFilterTree.checked?loadMenuTree():showGroups()"></SELECT>
			<INPUT type="button" value="  ADD  " onclick="addGroup()">
			<label For="chkFilterTree">Filter Tree</label><input type="checkbox" id="chkFilterTree" style="border:none" onclick="loadMenuTree()" />
			<BR>
			<TABLE datasrc="#xmlMenuGroups" cellpadding="0" cellspacing="0">
				<TR>
					<TD valign="top"><BUTTON onclick="removeMenuGroup(this)" style="PADDING-RIGHT: 0px;MARGIN-RIGHT: 5px; MARGIN-TOP: 0px; PADDING-LEFT: 1px; MARGIN-BOTTOM: -5px; PADDING-BOTTOM: 0px; FONT: icon; PADDING-TOP: 0px;BORDER: 1 solid black" title="Delete Group's Access">X</BUTTON></TD>
					<TD valign="top" style="padding-top:2px"><SPAN datafld="GroupName"></SPAN></TD>
					<TD valign="top"><INPUT datafld="Access" size="0" style="display:none"></TD>
					<TD valign="top" style="padding-left:5px">
						<TABLE datasrc="#xmlMenuGroups" datafld="AccessList" cellpadding="0" cellspacing="0" width="100%">
							<TR>
								<TD align="right" width="98%">
									<SPAN datafld="AccessID" id="spnAccess" style="display:none"></SPAN>
								</TD>
								<TD width="1%">
									<INPUT type="checkbox" datafld="Checked" style="border:none" id="chkAccess" onclick="updateMenuGroupAccess(this)">
								</TD>
								<TD width="1%" nowrap><SPAN datafld="AccessName"></SPAN></TD>
							</TR>
						</TABLE>
					</TD>
				</TR>
			</TABLE>
		</TD>
	</TR>
</TABLE>
<XML id="xmlMenuNS">
	<ASP:LITERAL ID="ltrMenuNS" Runat="server"></ASP:LITERAL>
</XML>
<XML id="xmlMenuGroups">
	<ASP:LITERAL ID="ltrMenuGroups" Runat="server"></ASP:LITERAL>
</XML>
</BODY>
<SCRIPT language="javascript" src="/include/Common.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/RDS.js"></SCRIPT>
<SCRIPT language="javascript" src="/include/SOAP.js"></SCRIPT>
<SCRIPT language="javascript" src="Common/Admin.js"></SCRIPT>
<SCRIPT language="javascript">
var nodeMenu;
function page_Load(){
	showGroups();
}
function loadMenuTree(){
	var ret = WS(CO("GetMenuTree"),chkFilterTree.checked?selGroups.value:"");
	if( showSOAPError(ret) )return;
	oTree.innerHTML = ret.value;
	oTree.oncontentready();
	oTree.selectedNodeIndex = 0;
	if( oTree.selectedNodeIndex == "" )return;
	showGroups();
}
function removeMenuGroup(el){
	if( !confirm("Delete "+_groupName(el)+" group from selected menu?") )return;
	var ret = WS(CO("MenuGroup_Rem"),selNS.value,_groupName(el),_menuID());
	if( showSOAPError(ret) )return;
	showGroups();
}
function removeMenuNS(el){
	if( !confirm("Delete "+_nameSpace(el)+" NameSpace from selected menu?") )return;
	var ret = WS(CO("MenuNS_Rem"),_nameSpace(el),_menuID());
	if( showSOAPError(ret) )return;
}
function updateMenuGroupAccess(el){
	if( typeof(updateMenuGroupAccess_V) != 'undefined' )
		return updateMenuGroupAccess_V(el);
	var tbl = getParentByTag(el,"TABLE");
	var spns = tbl.all.spnAccess;
	var chks = tbl.all.chkAccess;
	if( fieldByName(el,"AccessID") != -1 && !el.checked )chks[0].checked = false;
	for( var i=1,n=_mult(spns[0],chks[0]); i < spns.length; i++ )
		if( fieldByName(el,"AccessID") == -1 )chks[i].checked = el.checked;
		else n += _mult(spns[i],chks[i]);
	if( n == Math.pow(2,i-1)-1 )chks[0].checked = true;
	if( chks[0].checked && n > 0 )return updateMenuGroupAccess(chks[0]);
	var ret = WS(CO("MenuGroup_Update"),selNS.value,_groupName(tbl),_menuID(),n);
	if( showSOAPError(ret) )return;
	if( n != ret.value )return alert("Returned Access["+ret.value+"] does not match calculated["+n+"]");
	var access = elementByDataFld(tbl,"Access");
	access.value = n;
	// Local
	function _mult(spn,chk){return parseInt(spn.innerText)*(chk.checked?1:0)}
}
function addNS(){
	var ret = WS(CO("MenuNS_Add"),selNS.value,_menuID());
	if( showSOAPError(ret) )return;
}
function addGroup(){
	var ret = WS(CO("MenuGroup_Add"),selNS.value,selGroups.value,_menuID());
	if( showSOAPError(ret) )return;
	showGroups();
}
function showGroups(){
	if( !checkWS(true) )return setTimeout("showGroups()",500);
	if( (event||{}).newTreeNodeIndex )nodeMenu = oTree.getTreeNode(event.newTreeNodeIndex);
	else nodeMenu = oTree.getTreeNode(oTree.selectedNodeIndex);
	var ret = WS(CO("MenuGroups_Get"),selNS.value,_menuID(),selGroups.value);
	if( showSOAPError(ret) )return;
	xmlMenuGroups.loadXML(ret.value);
}
function showNS(){
	var ret = WS(CO("MenuNS_Get"),_menuID());
	if( showSOAPError(ret) )return;
	xmlMenuNS.loadXML(ret.value);
}
function _nameSpace(el){return fieldByName(el,"nameSpace")}
function _groupName(el){return fieldByName(el,"GroupName")}
function _menuID(){return nodeMenu.getAttribute("MenuID")}
</SCRIPT>
</html>
